package com.um2.qualite;

import junit.framework.TestCase;

public class TowerTest extends TestCase {

	Tower t1 ;
	Tower t2 ;
	
	protected void setUp() throws Exception {
	}

	public final void testGetCapacity() {
		t1 = new Tower(3) ;
		assertTrue(t1.getCapacity()==3) ;
	}

	public final void testGetDisk() {
		t1 = new Tower(3) ;
		Disk d = new Disk(4) ;
		t1.push(d) ;
		assertTrue(t1.getDisk(0)==d) ;
	}

	public final void testGetTopDisk() {
		t1 = new Tower(3) ;
		Disk d1 = new Disk(4) ;
		Disk d2 = new Disk(2) ;
		t1.push(d1) ;
		t1.push(d2) ;
		assertTrue(t1.getTopDisk().equals(d2)) ;
	}

	public final void testIsEmpty() {
		t1 = new Tower(3) ;
		assertTrue(t1.isEmpty()) ;
	}

	public final void testIsEmpty2() {
		t1 = new Tower(3) ;
		Disk d = new Disk(4) ;
		t1.push(d) ;
		assertFalse(t1.isEmpty()) ;
	}

	public final void testIsFull() {
		t1 = new Tower(3) ;
		Disk d1 = new Disk(4) ;
		Disk d2 = new Disk(3) ;
		Disk d3 = new Disk(2) ;
		t1.push(d1) ;
		t1.push(d2) ;
		t1.push(d3) ;
		assertTrue(t1.isFull()) ;
	}

	public final void testIsFull2() {
		t1 = new Tower(3) ;
		Disk d1 = new Disk(4) ;
		Disk d2 = new Disk(3) ;
		t1.push(d1) ;
		t1.push(d2) ;
		assertFalse(t1.isFull()) ;
	}

	public final void testIsStackable() {
		t1 = new Tower(3) ;
		Disk d1 = new Disk(4) ;
		Disk d2 = new Disk(3) ;
		t1.push(d1) ;
		assertTrue(t1.isStackable(d2)) ;
	}

	public final void testIsStackable2() {
		t1 = new Tower(3) ;
		Disk d1 = new Disk(4) ;
		Disk d2 = new Disk(5) ;
		t1.push(d1) ;
		assertFalse(t1.isStackable(d2)) ;
	}

	public final void testPop() {
		t1 = new Tower(3) ;
		Disk d1 = new Disk(4) ;
		Disk d2 = new Disk(5) ;
		t1.push(d1) ;
		t1.push(d2) ;
		assertTrue(t1.pop().equals(d2)) ;
	}

	public final void testPush() {
		t1 = new Tower(3) ;
		Disk d1 = new Disk(4) ;
		Disk d2 = new Disk(2) ;
		t1.push(d1) ;
		t1.push(d2) ;
		assertTrue(t1.getTopDisk().equals(d2)) ;
	}

	public final void testGetDiskNb() {
		t1 = new Tower(4) ;
		Disk d1 = new Disk(4) ;
		Disk d2 = new Disk(3) ;
		Disk d3 = new Disk(1) ;
		t1.push(d1) ;
		t1.push(d2) ;
		t1.push(d3) ;
		assertTrue(t1.getDiskNb()==3) ;
	}

	public final void testToString() {
		t1 = new Tower(4) ;
		assertTrue(t1.toString().equals("\n(Empty) \n")) ;
	}

	public final void testToString2() {
		t1 = new Tower(4) ;
		Disk d1 = new Disk(4) ;
		Disk d2 = new Disk(3) ;
		Disk d3 = new Disk(1) ;
		t1.push(d1) ;
		t1.push(d2) ;
		t1.push(d3) ;
		assertTrue(t1.toString().equals("X\nXXX\nXXXX\n")) ;
	}

}
